package com.szxy.hotel.mapper;

import com.szxy.hotel.entity.Vip;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VipMapper {

    @Insert("insert into vip (vip_name,vip_money,vip_type,vip_discount,vip_dis_double) values(#{userName},#{money},#{vipType},#{vipDiscount},#{vipDisDouble})")
    @ResultMap("VipResultMap")
    void insertVip(@Param("userName") String userName,@Param("money") Double money,@Param("vipType") String vipType,@Param("vipDiscount") String vipDiscount,@Param("vipDisDouble") Double vipDisDouble);

    @Update("update vip set vip_money=#{money},vip_type=#{vipType},vip_discount=#{vipDiscount},vip_dis_double=#{vipDisDouble} where vip_name = #{userName}")
    @ResultMap("VipResultMap")
    void updateVip(@Param("userName") String userName,@Param("money") Double money,@Param("vipType") String vipType,@Param("vipDiscount") String vipDiscount,@Param("vipDisDouble") Double vipDisDouble);

    @Update("update vip set vip_money=#{money} where vip_name = #{userName}")
    @ResultMap("VipResultMap")
    void updateVipMoney(@Param("userName") String userName,@Param("money") Double money);

    @Select("select v.vip_name vname,v.vip_type vtype,v.vip_discount vdiscount,c.client_phone cphone,c.client_identity cidentity,c.client_money cmoney from vip v,client c where v.vip_name = c.client_name limit #{start},#{size}")
    @ResultMap("VipClientResult")
    List<Vip> findByPage(@Param("start") int start,@Param("size") int size);

    @Select("select * from vip")
    @ResultMap("VipResultMap")
    List<Vip> selectCount();

    @Select("select * from vip where vip_name = #{roomName}")
    @ResultMap("VipResultMap")
    Vip selectByName(@Param("roomName") String roomName);
}